<?php
class DebugUtil{

    const GRADE_START= '<table border="1"><tr><td>';
    const GRADE_END= '</td></tr></table>';

    public static $enable = false;

    public static function dump(&$var, $file, $line, $format='HTML'){
        if(self::$enable){
            if(strtoupper($format) == 'TEXT'){
                self::textDump($var, $file, $line);
            }else{
                self::htmlDump($var, $file, $line);
            }
        }
    }

    public static function point($file, $line, $format='HTML'){
        if(self::$enable){
            if(strtoupper($format) == 'TEXT'){
                self::textPoint($file, $line);
            }else{
                self::htmlPoint($file, $line);
            }
        }
    }

    private static function htmlPoint($file, $line){
        if(self::$enable){
            echo "<p>[$file][$line]</p>";
        }
    }

    private static function textPoint($file, $line){
        if(self::$enable){
            echo "\n[$file][$line]\n\n";
        }
    }

    private static function htmlDump(&$var, $file, $line){
        if(self::$enable){
            echo "<h3>[$file][$line]</h3>";
            echo "<pre>";
            var_dump($var);
            echo "</pre>";
        }
    }

    private static function textDump(&$var, $file, $line){
        if(self::$enable){
            echo "\n[$file][$line]\n";
            var_dump($var);

            echo "\n\n";
        }
    }
}
